import sys
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QMainWindow, QDockWidget, QApplication, QLineEdit 
from PySide6.QtWidgets import QPushButton, QTableWidget, QTableWidgetItem

# 更新字典 {车辆编号：树莓派IP} 

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        ref_ip = {"1":"192.168.0.125",
                  "2":"192.169.0.126",}
        '''主窗口'''
        self.setWindowTitle("fs") # 主窗口名
        # 字典表格
        self.table_dict = QTableWidget()
        self.table_dict.setRowCount(len(ref_ip)) # 行数
        #self.table_dict.setRowHeight(0, 20) # 行高
        self.table_dict.setColumnCount(2) # 列数
        self.table_dict.setColumnWidth(1, 200) # 列宽
        self.table_dict.setHorizontalHeaderLabels(["车辆编号", "车辆IP"])
        self.setCentralWidget(self.table_dict)

        for index,key in enumerate(ref_ip):
            ip = QTableWidgetItem(ref_ip[key])
            ref = QTableWidgetItem(key)
            self.table_dict.setItem(index, 0, ref)
            self.table_dict.setItem(index, 1, ip)

def main(args=None):
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec())

if __name__ == '__main__':
    main()